<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}后台管理 - Meet活动聚{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        :root {
            --primary: #4361ee;
            --secondary: #6c757d;
            --success: #28a745;
            --info: #17a2b8;
            --warning: #ffc107;
            --danger: #dc3545;
            --light: #f8f9fa;
            --dark: #343a40;
            --sidebar-bg: #2c3e50;
            --sidebar-hover: #34495e;
            --header-bg: #ffffff;
            --card-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
        }

        body {
            background-color: #f8f9fc;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        .sidebar {
            min-height: 100vh;
            background: var(--sidebar-bg);
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
            transition: all 0.3s;
        }

        .sidebar .nav-link {
            color: #b7c0cd;
            padding: 0.75rem 1rem;
            margin: 0.2rem 0;
            border-radius: 0.35rem;
            transition: all 0.3s;
        }

        .sidebar .nav-link:hover {
            color: #fff;
            background: var(--sidebar-hover);
            transform: translateX(5px);
        }

        .sidebar .nav-link.active {
            color: #fff;
            background: var(--primary);
            box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
        }

        .sidebar .nav-link i {
            margin-right: 0.5rem;
            width: 20px;
            text-align: center;
        }

        .sidebar-brand {
            font-weight: 700;
            font-size: 1.2rem;
            color: #fff;
            padding: 1.5rem 1rem;
            text-align: center;
            background: rgba(0, 0, 0, 0.1);
            margin-bottom: 1rem;
        }

        .main-content {
            background-color: #f8f9fc;
            min-height: 100vh;
        }

        .page-header {
            background: var(--header-bg);
            border-bottom: 1px solid #e3e6f0;
            padding: 1.5rem 0;
            margin-bottom: 1.5rem;
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
        }

        .card {
            border: none;
            box-shadow: var(--card-shadow);
            border-radius: 0.5rem;
            margin-bottom: 1.5rem;
            transition: all 0.3s;
        }

        .card:hover {
            box-shadow: 0 0.5rem 2rem 0 rgba(58, 59, 69, 0.2);
        }

        .card-header {
            background: #fff;
            border-bottom: 1px solid #e3e6f0;
            padding: 1rem 1.5rem;
            font-weight: 600;
        }

        .table th {
            border-top: none;
            font-weight: 600;
            color: var(--dark);
            background: #f8f9fc;
        }

        .btn {
            border-radius: 0.35rem;
            font-weight: 500;
            transition: all 0.3s;
        }

        .stats-card {
            border-left: 4px solid;
            transition: transform 0.2s;
        }

        .stats-card:hover {
            transform: translateY(-5px);
        }

        .badge {
            font-weight: 500;
            padding: 0.35em 0.65em;
        }

        .pagination .page-link {
            color: var(--primary);
            border-radius: 0.35rem;
            margin: 0 0.2rem;
        }

        .pagination .page-item.active .page-link {
            background: var(--primary);
            border-color: var(--primary);
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <!-- 侧边栏 -->
            <nav id="sidebar" class="col-md-3 col-lg-2 d-md-block sidebar">
                <div class="position-sticky">
                    <div class="sidebar-brand">
                        <i class="bi bi-geo-alt me-2"></i>本地有约后台
                    </div>
                    <div class="text-center mb-4">
                        <small class="text-light opacity-75">管理员: {{ request.user.username }}</small>
                    </div>

                    <ul class="nav flex-column">
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'admin_dashboard' %}active{% endif %}"
                               href="{% url 'dashboard:admin_dashboard' %}">
                                <i class="bi bi-speedometer2"></i>
                                后台管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'user_management' %}active{% endif %}"
                               href="{% url 'dashboard:user_management' %}">
                                <i class="bi bi-people"></i>
                                用户管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'activity_management' %}active{% endif %}"
                               href="{% url 'dashboard:activity_management' %}">
                                <i class="bi bi-calendar-event"></i>
                                活动管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'category_management' %}active{% endif %}"
                               href="{% url 'dashboard:category_management' %}">
                                <i class="bi bi-tags"></i>
                                分类管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'points_management' %}active{% endif %}"
                               href="{% url 'dashboard:points_management' %}">
                                <i class="bi bi-coin"></i> 积分管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'rewards_management' %}active{% endif %}"
                               href="{% url 'dashboard:rewards_management' %}">
                                <i class="bi bi-gift"></i> 奖品管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'system_analytics' %}active{% endif %}"
                               href="{% url 'dashboard:system_analytics' %}">
                                <i class="bi bi-graph-up"></i>
                                系统数据分析
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {% if request.resolver_match.url_name == 'admin_logs' %}active{% endif %}"
                               href="{% url 'dashboard:admin_logs' %}">
                                <i class="bi bi-journal-text"></i>
                                操作日志
                            </a>
                        </li>
                    </ul>

                    <div class="mt-4 p-3 border-top border-secondary">
                        <a href="{% url 'home' %}" class="btn btn-outline-light btn-sm w-100 mb-2">
                            <i class="bi bi-house me-1"></i>返回前台
                        </a>
                        <a href="{% url 'admin:index' %}" class="btn btn-light btn-sm w-100">
                            <i class="bi bi-gear me-1"></i>高级管理
                        </a>
                    </div>
                </div>
            </nav>

            <!-- 主内容 -->
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 main-content">
                {% if messages %}
                    {% for message in messages %}
                        <div class="alert alert-{{ message.tags }} alert-dismissible fade show mt-3" role="alert">
                            <i class="bi bi-{% if message.tags == 'success' %}check-circle{% elif message.tags == 'warning' %}exclamation-triangle{% elif message.tags == 'error' %}x-circle{% else %}info-circle{% endif %} me-2"></i>
                            {{ message }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                        </div>
                    {% endfor %}
                {% endif %}

                {% block content %}
                {% endblock %}
            </main>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    {% block extra_js %}{% endblock %}
</body>
</html>